(in-package :graph-io)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Save information for various model classes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-save-info arc
  (:origin origin)
  (:extremity extremity))

(define-save-info node
  (:out-arcs node-out-arcs))

(define-save-info weight-mixin
  (:weight weight))

(define-save-info graph
  (:nodes graph-nodes)
  (:arcs graph-arcs))

(define-save-info label-mixin
  (:label label))

(define-save-info oriented-mixin
  (:oriented-p oriented-p))

(define-save-info num-mixin
  (:num num))

(defvar *graph-allowed-version-names* '("GraphV1" "GraphV1.1"))
(defvar *graph-current-version-name*  "GraphV1.1")

(defun read-graph-from-stream (stream)
  (read-model-from-stream stream *graph-allowed-version-names*))

(defun write-graph-to-stream (stream object)
  (write-model-to-stream stream *graph-current-version-name* object))

(defun read-graph (filename)
  (read-model filename *graph-allowed-version-names*))

(defun write-graph (filename object)
  (write-model filename *graph-current-version-name* object))

(defmethod copy-graph ((graph graph))
  (copy-model graph *graph-current-version-name*))
